package tests;

import java.util.ArrayList;
import models.Track;

public class MockMeasure {
public String content;
	
	public void generateMeasures(Track newTrackModel, int instrumentNum, int octave, ArrayList<Double> prevLengths, ArrayList<Integer> prevValues)
	{
		final int SEMI_TONE_COUNT = 12;
		
		int[] naturalNoteValues = new int[]{0, 2, 4, 5, 7, 9, 11};
		
		int noteValue;
		double noteLength;
		StringBuilder generatedString = new StringBuilder();;
		double measure;
		
		for(int k=0; k < newTrackModel.measuresPerPhrase; k++)
		{
			if(!newTrackModel.harmonic || instrumentNum < 1)
			{
				measure = 1;
				do
				{
					
						noteValue = naturalNoteValues[k] + (5 * SEMI_TONE_COUNT);
						prevValues.add(noteValue);
						noteLength = (1.0/4);
						prevLengths.add(noteLength);
						measure -= noteLength;
						
						generatedString.append("[" + noteValue + "]/" + noteLength + " ");
					
				}
				while(measure > 0);
			}
			else if(newTrackModel.harmonic)
			{
				measure = 1;
				do
				{
					
						noteValue = prevValues.get(k);
						noteLength = prevLengths.get(k);
						measure -= noteLength;
						
						generatedString.append("[" + (noteValue + 5) + "]/" + noteLength + " ");
					
				}
				while(measure > 0);
			}
			generatedString.append("| ");
		}
		content = generatedString.toString();
	}
}
